HA$PBExportHeader$w_mmovimiento_param.srw
forward
global type w_mmovimiento_param from window
end type
type ddlb_ejercicio from uo_middlb within w_mmovimiento_param
end type
type st_4 from statictext within w_mmovimiento_param
end type
type ddlb_almacen from uo_middlb within w_mmovimiento_param
end type
type ddlb_tienda from uo_middlb within w_mmovimiento_param
end type
type ddlb_mes from ddlb_meses within w_mmovimiento_param
end type
type st_3 from statictext within w_mmovimiento_param
end type
type st_2 from statictext within w_mmovimiento_param
end type
type st_1 from statictext within w_mmovimiento_param
end type
type cb_cancelar from commandbutton within w_mmovimiento_param
end type
type cb_aceptar from commandbutton within w_mmovimiento_param
end type
end forward

global type w_mmovimiento_param from window
integer width = 1513
integer height = 824
boolean titlebar = true
string title = "PARAMETROS DE ALMACENES"
boolean controlmenu = true
windowtype windowtype = response!
long backcolor = 67108864
string icon = "Structure5!"
boolean center = true
ddlb_ejercicio ddlb_ejercicio
st_4 st_4
ddlb_almacen ddlb_almacen
ddlb_tienda ddlb_tienda
ddlb_mes ddlb_mes
st_3 st_3
st_2 st_2
st_1 st_1
cb_cancelar cb_cancelar
cb_aceptar cb_aceptar
end type
global w_mmovimiento_param w_mmovimiento_param

type variables
datastore ids_datastore
s_parm istr_parm
u_cst_powerdock uo_powerdock
userobject iuo_userObject[]
string is_titulo,is_imagen,is_userobject,isa_alma[],is_alma,isa_tienda[] ,is_tienda
integer ii_tabindex,iia_ejercicio[]
boolean ib_Indicador_Cierre = false 
u_cst_grillamaincabedet iuo_grillamain
end variables

on w_mmovimiento_param.create
this.ddlb_ejercicio=create ddlb_ejercicio
this.st_4=create st_4
this.ddlb_almacen=create ddlb_almacen
this.ddlb_tienda=create ddlb_tienda
this.ddlb_mes=create ddlb_mes
this.st_3=create st_3
this.st_2=create st_2
this.st_1=create st_1
this.cb_cancelar=create cb_cancelar
this.cb_aceptar=create cb_aceptar
this.Control[]={this.ddlb_ejercicio,&
this.st_4,&
this.ddlb_almacen,&
this.ddlb_tienda,&
this.ddlb_mes,&
this.st_3,&
this.st_2,&
this.st_1,&
this.cb_cancelar,&
this.cb_aceptar}
end on

on w_mmovimiento_param.destroy
destroy(this.ddlb_ejercicio)
destroy(this.st_4)
destroy(this.ddlb_almacen)
destroy(this.ddlb_tienda)
destroy(this.ddlb_mes)
destroy(this.st_3)
destroy(this.st_2)
destroy(this.st_1)
destroy(this.cb_cancelar)
destroy(this.cb_aceptar)
end on

event open;string ls_dw
string ls_titulo,ls_imagen,ls_userobject,ls_tabtitulo,ls_tipo,ls_window
long ll_count,ll_fila,ll_resul
integer li_window,li_fila,li_tienda

istr_parm = message.powerobjectparm 
for li_fila = 1 to UpperBound(isa_tienda[])  
	 if integer(isa_tienda[li_fila]) = istr_parm.integer_parm[1]  then 
		ddlb_tienda.selectitem(li_fila)
		istr_parm.integer_parm[1]=integer(isa_tienda[li_fila])
		li_tienda=	istr_parm.integer_parm[1]
		EXIT 
	end if
next
ddlb_almacen.reset( )
ddlb_almacen.event ue_rellena('select idalma,tdesc from malmacen where idcentro ="'+string(li_tienda)+'" order by 1 asc')

for li_fila = 1 to UpperBound(isa_alma[])  
	 if integer(isa_alma[li_fila]) = istr_parm.integer_parm[2]  then 
		ddlb_almacen.selectitem(li_fila)
		istr_parm.integer_parm[2]=integer(isa_alma[li_fila])
		EXIT 
	end if
next

for li_fila = 1 to UpperBound(iia_ejercicio[])  
	 if iia_ejercicio[li_fila] = istr_parm.integer_parm[4]  then 
		ddlb_ejercicio.selectitem(li_fila)
		istr_parm.integer_parm[4]=iia_ejercicio[li_fila]
		EXIT 
	end if
next

ddlb_mes.selectitem( month(today()))
istr_parm.char_parm[1]='0'

//uo_toolbarstrip.visible = false
//dw_1.visible = false
//of_getwindow()
ids_datastore   = istr_parm.ads_menu //aqui recupera el datastore
is_userobject 				  = ids_datastore.object.tUserObject[1]
iuo_grillamain  = istr_parm.auo_grillamaincabedet
is_titulo 						  = ids_datastore.object.tDesc[1]
is_imagen  					   = ids_datastore.object.tTabImg[1]
uo_powerdock = istr_parm.auo_powerdock 
//is_button         = istr_parm.as_button
ls_dw              = ids_datastore.object.tDw1[1]
//f_msg(ls_dw,4)
//ls_dw2              = ids_datastore.object.tDw2[1]
//is_tabla           = ids_datastore.object.tTabla[1]
//is_entidad = ids_datastore.object.tEntidad[1]
//iuo_tab            = istr_parm.auo_userobject 
//iuo_grillamain  = istr_parm.auo_grillamaincabedet
//iuo_tabmantomain = istr_parm.auo_tabmantocabedet
//is_idcodigo			=  istr_parm.as_parm[1] //id tabla
//if ls_dw = '' or isnull(ls_dw) then return
end event

event close;if not ib_Indicador_Cierre then
	ib_Indicador_Cierre = True
	closewithreturn(this,istr_parm)
end if 
end event

type ddlb_ejercicio from uo_middlb within w_mmovimiento_param
integer x = 549
integer y = 304
integer width = 453
integer height = 456
integer taborder = 20
end type

event constructor;call super::constructor;event ue_rellena('select idEjercicio,idEjercicio from MEJERCICIO order by 1 asc')
end event

event ue_rellena;long ll_indice= 1
setpointer(hourglass!)

string ls_campo[]
prepare sqlsa from :as_cadena;
declare cur01 dynamic cursor for sqlsa;
open dynamic cur01 ;
fetch cur01 into :iia_ejercicio[1], :is_columna2[1];
do while sqlca.sqlcode=0 
	this.additem(is_columna2[ll_indice])
	ll_indice++
	fetch cur01 into :iia_ejercicio[ll_indice], :is_columna2[ll_indice];
loop
if sqlca.sqlcode = -1 then
   return -1
else
	close cur01 ;
	return 1
end if
setpointer(arrow!)

end event

event selectionchanged;call super::selectionchanged;if index <=0 then return
istr_parm.integer_parm[4] = iia_ejercicio [index]
end event

type st_4 from statictext within w_mmovimiento_param
integer x = 32
integer y = 308
integer width = 475
integer height = 64
integer textsize = -8
integer weight = 700
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
long textcolor = 33554432
long backcolor = 67108864
string text = "A$$HEX1$$f100$$ENDHEX$$o:"
boolean focusrectangle = false
end type

type ddlb_almacen from uo_middlb within w_mmovimiento_param
integer x = 539
integer y = 164
integer width = 905
integer height = 456
integer taborder = 50
end type

event selectionchanged;call super::selectionchanged;
istr_parm.integer_parm[2]=integer(isa_alma[index] )
end event

event ue_rellena;long ll_indice= 1
setpointer(hourglass!)

string ls_campo[]
prepare sqlsa from :as_cadena;
declare cur01 dynamic cursor for sqlsa;
open dynamic cur01 ;
fetch cur01 into :isa_alma[1], :is_columna2[1];
do while sqlca.sqlcode=0 
	this.additem(is_columna2[ll_indice])
	ll_indice++
	fetch cur01 into :isa_alma[ll_indice], :is_columna2[ll_indice];
loop
if sqlca.sqlcode = -1 then
   return -1
else
	close cur01 ;
	return 1
end if
setpointer(arrow!)



end event

event constructor;call super::constructor;//ddlb_almacen.event ue_rellena('select idalma,tdesc from malmacen where idcentro ="'+string(1)+'" order by 1 asc')
end event

type ddlb_tienda from uo_middlb within w_mmovimiento_param
integer x = 539
integer y = 28
integer width = 901
integer height = 420
integer taborder = 40
end type

event constructor;call super::constructor;event ue_rellena('select idcentro,tdesc from mcentro order by 1 asc')

end event

event selectionchanged;call super::selectionchanged;
istr_parm.integer_parm[1]=integer(isa_tienda[index] )

ddlb_almacen.reset( )
ddlb_almacen.event ue_rellena('select idalma,tdesc from malmacen where idcentro ="'+string(istr_parm.integer_parm[1])+'" order by 1 asc')


end event

event ue_rellena;long ll_indice= 1
setpointer(hourglass!)

string ls_campo[]
prepare sqlsa from :as_cadena;
declare cur01 dynamic cursor for sqlsa;
open dynamic cur01 ;
fetch cur01 into :isa_tienda[1], :is_columna2[1];
do while sqlca.sqlcode=0 
	this.additem(is_columna2[ll_indice])
	ll_indice++
	fetch cur01 into :isa_tienda[ll_indice], :is_columna2[ll_indice];
loop
if sqlca.sqlcode = -1 then
   return -1
else
	close cur01 ;
	return 1
end if
setpointer(arrow!)




end event

type ddlb_mes from ddlb_meses within w_mmovimiento_param
integer x = 553
integer y = 432
integer width = 901
integer taborder = 30
end type

event selectionchanged;call super::selectionchanged;if index <=0 then return
istr_parm.integer_parm[3]=index
end event

type st_3 from statictext within w_mmovimiento_param
integer x = 32
integer y = 452
integer width = 475
integer height = 64
integer textsize = -8
integer weight = 700
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
long textcolor = 33554432
long backcolor = 67108864
string text = "Periodo:"
boolean focusrectangle = false
end type

type st_2 from statictext within w_mmovimiento_param
integer x = 32
integer y = 168
integer width = 475
integer height = 64
integer textsize = -8
integer weight = 700
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
long textcolor = 33554432
long backcolor = 67108864
string text = "Almacen:"
boolean focusrectangle = false
end type

type st_1 from statictext within w_mmovimiento_param
integer x = 32
integer y = 40
integer width = 475
integer height = 64
integer textsize = -8
integer weight = 700
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
long textcolor = 33554432
long backcolor = 67108864
string text = "Centro o Tienda:"
boolean focusrectangle = false
end type

type cb_cancelar from commandbutton within w_mmovimiento_param
integer x = 782
integer y = 588
integer width = 402
integer height = 112
integer taborder = 20
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
string text = "&Cancelar"
end type

event clicked;closewithreturn(parent,istr_parm)
end event

type cb_aceptar from commandbutton within w_mmovimiento_param
integer x = 320
integer y = 588
integer width = 402
integer height = 112
integer taborder = 10
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
string text = "&Aceptar"
end type

event clicked;long ll_return,ll_alma

ll_return = 0
ll_alma  = long(istr_parm.integer_parm[2] )
sqlca.Usp_GetUserAlma( gs_iduser,ll_alma, ll_return)

if ll_return = -1 then
	f_msj('No tiene acceso al almacen seleccionado',4); return
elseif ll_return = 0  then
	f_msj('El almacen seleccionado esta desactivado',4); return
end if

istr_parm.char_parm[1]='1'
//istr_parm.auo_grillamaincabedet = iuo_grillamain
cb_cancelar.event post clicked()

//If istr_parm.string_parm[1]='P' Then
//	iuo_grillamain.Dynamic of_setparm (istr_parm.integer_parm[1],istr_parm.integer_parm[2],istr_parm.integer_parm[3])
//	iuo_grillamain.Dynamic Event  ue_actualizar() 
//	
//End if
//	ii_tabindex ++
//	uo_PowerDock.of_opendocument( iuo_userObject[ii_tabindex],istr_parm,is_titulo ,is_imagen,is_userobject)
//End if
//cb_2.triggerevent( clicked!)
end event

